'use strict';

import { Application } from 'egg';
import * as moment from 'moment'

export default function(app: Application) {
  const { STRING, INTEGER} = app.Sequelize;
  const Admin = app.model.define('admin', {
    admin_id: { type: INTEGER, unique: true, autoIncrement: true, primaryKey: true },
    user_name: { type: STRING, allowNull: true },
    email:{ type: STRING, allowNull: true},
    password:{type:STRING,allowNull:false},
    real_name:{type:STRING},
    create_time: { 
      type: STRING,
      get:function(){
        return moment(this['dataValues']["create_time"]).format('YYYY-MM-DD HH:mm:ss')
      }
    },
    phone: { type: STRING},
  },{
    tableName:'admin',
    timestamps: false,
  });
  

  return class extends Admin {
    static associate() {
      //app.model.User.hasMany(app.model.Post, { as: 'posts' });
    }
  }
}